;
(function() {
  'use strict';
  angular.module('services.accessSystem.accessResult', [])
    .service('accessResultService', accessResultService);

  function accessResultService(Restangular, $filter) {
    return {
      queryTimeTypes: queryTimeTypes,
      queryAccessResult: queryAccessResult,
      sendTitle: sendTitle,
      sendData: sendData
    };
    //查询统计方式
    function queryTimeTypes(callback) {
      Restangular.one('sas/accessSystem/timeTypes/query').get().then(callback);
    }
    //查询考核结果
    function queryAccessResult(params, callback) {
      Restangular.all('sas/accessSystem/accessResult/query').post(params).then(callback);
    }

    function sendTitle(send) {
      var title = '';
      if (send.timeTypeCode === '5') {
        title = send.date + '年统一支付考核结果统计';
      } else if (send.timeTypeCode === '3') {
        title = $filter('date')(send.date, 'yyyy年MM月') + '统一支付考核结果统计';
      } else {
        title = $filter('date')(send.date, 'yyyy年MM月dd日') + '统一支付考核结果统计';
      }
      return title;
    }

    function sendData(send) {
      var sendData = {
        timeTypeCode: send.timeTypeCode,
        date: ''
      };
      if (send.timeTypeCode === '5') {
        sendData.date = send.date.toString();
      } else if (send.timeTypeCode === '3') {
        sendData.date = $filter('date')(send.date, 'yyyy-MM');
      } else {
        sendData.date = $filter('date')(send.date, 'yyyy-MM-dd');
      }
      return sendData;
    }
  }

})();